//
//  Macro.h
//  circum
//
//  Created by sunbin on 2017/5/28.
//  Copyright © 2017年 HuaYue. All rights reserved.
//

#ifndef Macro_h
#define Macro_h


//颜色
#define RGB(x,y,z) [UIColor colorWithRed:(x/255.0) green:(y/255.0) blue:(z/255.0) alpha:1]
#define RGBA(r,g,b,a)      [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define ThemeColor RGB(4,142,255)
#define BacksColor RGB(241,241,241)
#define LinesColor RGB(239,239,239)
#define priceColor RGB(241, 90, 36)
#define BlaTiColor RGB(77, 77, 77)

//NSLog 设置
#ifdef DEBUG
#define HYLog(...) NSLog(__VA_ARGS__)
#else
#define HYLog(...)
#endif

#define STATUS_BAR_BIGGER_THAN_20 [UIApplication sharedApplication].statusBarFrame.size.height > 20

#define kEnglishKeyboardHeight  (216.f)
#define kChineseKeyboardHeight  (252.f)

#define STATUS_BAR_HEIGHT 20
#define NAVIGATION_BAR_HEIGHT 44
#define BOTTOMB_BAR_HEIGHT        (49.f)
#define STATUS_AND_NAVIGATION_HEIGHT ((STATUS_BAR_HEIGHT) + (NAVIGATION_BAR_HEIGHT))

#define SCREEN_RECT    ([UIScreen mainScreen].bounds)
#define SCREEN_WIDTH   ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT  ([UIScreen mainScreen].bounds.size.height)
#define CONTENT_HEIGHT (SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - STATUS_BAR_HEIGHT)

#define kMainScreenHeight ([UIScreen mainScreen].applicationFrame.size.height)
#define kMainScreenWidth  ([UIScreen mainScreen].applicationFrame.size.width)


#define X(v)        (v).frame.origin.x
#define Y(v)        (v).frame.origin.y
#define WIDTH(v)    (v).frame.size.width
#define HEIGHT(v)   (v).frame.size.height

#define MinX(v)                                                         CGRectGetMinX((v).frame)
#define MinY(v)                                                         CGRectGetMinY((v).frame)
#define MidX(v)                                                         CGRectGetMidX((v).frame)
#define MidY(v)                                                         CGRectGetMidY((v).frame)
#define MaxX(v)                                                         CGRectGetMaxX((v).frame)
#define MaxY(v)                                                         CGRectGetMaxY((v).frame)

#define RECT_CHANGE_x(v,x)                CGRectMake(x, Y(v), WIDTH(v), HEIGHT(v))
#define RECT_CHANGE_y(v,y)                CGRectMake(X(v), y, WIDTH(v), HEIGHT(v))
#define RECT_CHANGE_point(v,x,y)          CGRectMake(x, y, WIDTH(v),    HEIGHT(v))
#define RECT_CHANGE_width(v,w)            CGRectMake(X(v), Y(v), w,     HEIGHT(v))

#define RECT_CHANGE_height(v,h)           CGRectMake(X(v), Y(v), WIDTH(v), h)
#define RECT_CHANGE_size(v,w,h)           CGRectMake(X(v), Y(v), w,        h)




#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])

#define Iphone4 CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 480))?YES:NO
#define Iphone5 CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568))?YES:NO
#define Iphone6 CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667))?YES:NO
#define Iphone6Plus CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736))?YES:NO


//系统控件的默认高度
#define STATUSBAR_HEIGHT            (SCREEN_HEIGHT == 812.0f ? 44.0f : 20.0f)
#define NAVIGATIONBAR_HEIGHT        (44.0f)
#define STA_NAV_HEIGHT              (SCREEN_HEIGHT == 812.0f ? 88.0f : 64.0f)
#define TABBAR_HEIGHT               (49.0f)
#define CELL_HEIGHT                 (44.0f)
#define SCREER_HeiX            (SCREEN_HEIGHT == 812.0f ? 34.0f : 0.f)

//中英状态下键盘的高度
#define EN_KEYBOARD_HEIGHT          (216.0f)
#define CN_KEYBOARD_HEIGHT          (252.0f)

//显示比例
#define displayheight               (SCREEN_HEIGHT / 667.0f)
#define displaywidth                (SCREEN_WIDTH / 375.0f)

//字体比例
#define fontScale                   ((ceil(displaywidth) - 1) * 2)


#define LOADPathResource(file ,ext) [[NSBundle mainBundle] pathForResource:file ofType:ext]
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

//图片
#define IMAGE(imageName)  [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]
#define Icon(iconName)    [IMAGE(iconName) imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
#define PNGPATH(NAME)     [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"png"]
#define JPGPATH(NAME)     [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"jpg"]
#define PATH(NAME, EXT)   [[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]
#define PNGkImg(NAME)     [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"png"]]
#define JPGkImg(NAME)     [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"jpg"]]
#define kImg(NAME, EXT)   [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]]
#define V_IMAGE(imgName)  [UIImage imageNamed:imgName]

#define ImageAdress(imageUrl) [NSURL URLWithString:[ADRESS stringByAppendingString:imageUrl]]






#define kWindow             [[UIApplication sharedApplication] keyWindow]

#define kRootViewController [[[[UIApplication sharedApplication] keyWindow] objectAtIndex:0]rootViewController]
#define kAppDelegate ((AppDelegate*)([UIApplication sharedApplication].delegate))

#define sharedDelegate ((AppDelegate*)[[UIApplication sharedApplication]delegate])


#define kStoryboard(StoryboardName)                 [UIStoryboard storyboardWithName:StoryboardName bundle:nil]
#define kVCFromSb(storyboardId, storyboardName)     [[UIStoryboard storyboardWithName:storyboardName bundle:nil] \
instantiateViewControllerWithIdentifier:storyboardId]



#define TEXT_STRING(x)        [NSString stringWithFormat:@"%@",x]
#define IF_NULL_TO_STRING(x) ([(x) isEqual:[NSNull null]]||(x)==nil)? @"":TEXT_STRING(x)
#define IF_Binding(x ,y) ([(x) isEqual:[NSNull null]]||(x)==nil)? y:TEXT_STRING(x)

#define SEESEX(sex) ([IF_NULL_TO_STRING(sex) isBlank] || [IF_NULL_TO_STRING(sex) isEqualToString:@"0"])?@"保密":[IF_NULL_TO_STRING(sex) isEqualToString:@"1"]?@"男":@"女"




#define TEXT_Keep(x) [NSString stringWithFormat:@"%.2f",[x floatValue]]
#define NstringToInt(str) [str integerValue]

#define URL(url) [NSURL URLWithString:url]
#define string(str1,str2) [NSString stringWithFormat:@"%@%@",str1,str2]
#define s_str(str1) [NSString stringWithFormat:@"%@",str1]
#define s_Num(num1) [NSString stringWithFormat:@"%d",num1]
#define s_Integer(num1) [NSString stringWithFormat:@"%ld" ,num1]
#define s_percent(num1) [NSString stringWithFormat:@"%@%%",num1]

#define IntTranslateStr(int_str) [NSString stringWithFormat:@"%d",int_str];
#define FloatTranslateStr(float_str) [NSString stringWithFormat:@"%.2f",float_str];
#define UnsignedInteger_Int(uInt) [[NSNumber numberWithUnsignedInteger:uInt] integerValue]
#define Integer_str(integer) [integer integerValue]




#define LocalString(x, ...)     NSLocalizedString(x, nil)
#define AppLocalString(x, ...)  NSLocalizedStringFromTable(x, @"someName", nil)



#define USER_DEFAULT                 [NSUserDefaults standardUserDefaults]
#define SEEKPLISTTHING(KEY)          [[NSUserDefaults standardUserDefaults]objectForKey:KEY]
#define DEPOSITLISTTHING(VALUE,KEY)  [[NSUserDefaults standardUserDefaults] setObject:VALUE forKey:KEY]




#define kPathTemp NSTemporaryDirectory()
// 获取沙盒 Document
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
// 获取沙盒 Cache
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]

#define kFileManager [NSFileManager defaultManager]
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define PATH_OF_APP_HOME    NSHomeDirectory()
#define PATH_OF_TEMP        NSTemporaryDirectory()
#define PATH_OF_DOCUMENT    [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]


#define IS_LOGIN (((NSString *)SEEKPLISTTHING(USER_ID)).length > 0)
#define QL_USER_ID IF_NULL_TO_STRING(((NSString *)SEEKPLISTTHING(USER_ID)))
#define QL_USER_PHONE IF_NULL_TO_STRING(((NSString *)SEEKPLISTTHING(USER_PHONE)))
#define QL_USER_EASEMOB_NAME IF_NULL_TO_STRING(((NSString *)SEEKPLISTTHING(USER_EASEMOB_NAME)))


#pragma mark - degrees/radian functions由角度转换弧度 由弧度转换角度
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(radian) (radian*180.0)/(M_PI)


#define kDelay  1.5
#define delayRun dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kDelay * NSEC_PER_SEC)), dispatch_get_main_queue()
#define kDelay01  0.7
#define delayRun05 dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kDelay01 * NSEC_PER_SEC)), dispatch_get_main_queue()


#define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//GCD - 在Main线程上运行
#define kDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
//GCD - 开启异步线程
#define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);


#define CURRENTLANGUAGE         ([[NSLocale preferredLanguages] objectAtIndex:0])

#define WEAKSELF typeof(self) __weak weakSelf = self;
#define STRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf;


//检查系统版本
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)



#define appWidth [UIScreen mainScreen].bounds.size.width
#define appHeight [UIScreen mainScreen].bounds.size.height

#define appStatusBarHeight  [UIApplication sharedApplication].statusBarFrame.size.height
#define appNavigationBarHeight  self.navigationController.navigationBar.frame.size.height






#define kRGBAColor(r,g,b,a)    [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]








#define LEFTTEXT @"周边·关注周边的新闻"




#define MicrosoftYaHei(h) [UIFont fontWithName:@"MicrosoftYaHei" size:h] //不用了
































#endif
